<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/1/8
 * Time: 14:07
 */

namespace app\api\service;


class Config extends Base
{
    /**
     * @name 下发syslog配置文件
     * @author wx
     * @date 2020/1/8 14:08
     */
    function syslog()
    {
        $syslogPath = '../runtime/config/syslog.conf';

        if (!file_exists($syslogPath)) {
            $this->setError($this->CODE_FAIL,'no syslog config file');
            return 'fail';
        }

        $content = file_get_contents($syslogPath);
        $syslogConfig = json_decode($content, true);
        return $syslogConfig;

    }

    /**
     * @name 端口设置
     * @param $data
     * @author wx
     * @date 2020/1/8 14:52
     */
    function portConfig($data)
    {

        if(!empty($data)){
            foreach ($data as $type => $port){
                db('server_proxy')->where('type',$type)->update(['port' => $port]);
            }
        }

        return 'success';
    }

}